package com.ruoyi.project.bas.basJobId.controller;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.project.bas.basJobId.domain.BasJobId;
import com.ruoyi.project.bas.basJobId.service.IBasJobIdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * id表Controller
 * 
 * @author wz
 * @date 2021-11-05
 */
@Controller
@RequestMapping("/bas/basJobId")
public class BasJobIdController extends BaseController
{
    private String prefix = "bas/basJobId";

    @Autowired
    private IBasJobIdService basJobIdService;

    @GetMapping()
    public String basJobId()
    {
        return prefix + "/basJobId";
    }

    /**
     * 查询id表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasJobId basJobId)
    {
        startPage();
        List<BasJobId> list = basJobIdService.selectBasJobIdList(basJobId);
        return getDataTable(list);
    }

    /**
     * 导出id表列表
     */
    @Log(title = "id表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasJobId basJobId)
    {
        List<BasJobId> list = basJobIdService.selectBasJobIdList(basJobId);
        ExcelUtil<BasJobId> util = new ExcelUtil<BasJobId>(BasJobId.class);
        return util.exportExcel(list, "basJobId");

    }

    /**
     * 新增id表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存id表
     */
    @Log(title = "id表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasJobId basJobId)
    {
        return toAjax(basJobIdService.insertBasJobId(basJobId));
    }

    /**
     * 修改id表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        BasJobId basJobId = basJobIdService.selectBasJobIdById(id);
        mmap.put("basJobId", basJobId);
        return prefix + "/edit";
    }

    /**
     * 修改保存id表
     */
    @Log(title = "id表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasJobId basJobId)
    {
        return toAjax(basJobIdService.updateBasJobId(basJobId));
    }

    /**
     * 删除id表
     */
    @Log(title = "id表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basJobIdService.deleteBasJobIdByIds(ids));
    }
}
